﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ThermalEquipmentDesign.Model;
using System.Windows.Input;
using System.Windows;
using ThermalEquipmentDesign.Model.Condenser.EvaporaterR717;
using ThermalEquipmentDesign.View.Condenser;
using ThermalEquipmentDesign.Reference_Path;
using ThermalEquipmentDesign.Reference_Path.Condenser;

namespace ThermalEquipmentDesign.ViewModel.Condenser
{
    public class EvaporaterR717ViewModel : ObservableObject
    {
        // Declare fields for binding
        #region fields for binding
        private EvaporaterR717 oevaporaterR717 = new EvaporaterR717();
        private EvaporaterR717Result oevaporaterR717Result = new EvaporaterR717Result();
        private ICommand calculateEvaporaterR717;
        private String stooltip = "Press F1 for Help";
        #endregion

        // Create properties for binding
        #region properties for binding
        public String sTooltip
        {
            get { return stooltip; }
            set { stooltip = value; }
        }

        public EvaporaterR717 oEvaporaterR717
        {
            get { return oevaporaterR717; }
            set
            {
                if (value != oevaporaterR717)
                {
                    oevaporaterR717 = value;
                    OnPropertyChanged("oEvaporaterR717");                    
                }
            }
        }

        public EvaporaterR717Result oEvaporaterR717Result
        {
            get { return oevaporaterR717Result; }
            set {
                if (value != oevaporaterR717Result)
                {
                    oevaporaterR717Result = value;
                    OnPropertyChanged("oEvaporaterR717Result");
                }          
            }
        }

        public ICommand CalculateEvaporaterR717
        {
            get
            {
                if (calculateEvaporaterR717 == null)
                {
                    calculateEvaporaterR717 = new RelayCommand(
                        param => ImplementCalculationEvaporaterR717()
                    );
                }
                return calculateEvaporaterR717;
            }
        }
        #endregion

        /// <summary>
        /// Calculate design parameters for Evaporater Condenser
        /// </summary>
        public void ImplementCalculationEvaporaterR717()
        {            
            EvaporaterR717Model oEvaporaterR717Model = new EvaporaterR717Model();
            oevaporaterR717Result = oEvaporaterR717Model.ImplementCalculation(oevaporaterR717);
            EnthanpyInput a = new EnthanpyInput();
            a.DataContext = oEvaporaterR717Result;
            a.ShowDialog();
            oevaporaterR717Result = oEvaporaterR717Model.ImplementCalculation1(oevaporaterR717Result.dbSaturationEnthalpy);
        }
        //  Load Reference for the helping
        public void LoadReference(string sIndex)
        {
            System.Windows.Forms.Help.ShowHelp(null, ReferencePath.ReferenceFile, System.Windows.Forms.HelpNavigator.KeywordIndex, EvaporaterR717Reference.ResourceManager.GetString(sIndex));
        }
    }
}
    

